from django.db import models


# Create your models here.
class Grade(models.Model):
    name = models.CharField(max_length=20, verbose_name='班级名')
    count = models.IntegerField(verbose_name='班级人数')

    class Meta:
        db_table = 'grade'

    def __str__(self):
        return self.name


class Student(models.Model):
    name = models.CharField(max_length=20, verbose_name='学生名')
    age = models.IntegerField(verbose_name='学生年龄')
    grade = models.ForeignKey(Grade, on_delete=models.CASCADE, verbose_name='学生所在班级')

    class Meta:
        db_table = 'student'

    def __str__(self):
        return self.name
